package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.DbanForm;
import com.sample.javabean.Dban;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class DbanAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(DbanAction.class);
    	 	private Pager<Dban> pageList;
    	 	private Integer id;
    	 	private Dban dban=new Dban();
    	 	private DbanForm dbanForm=new DbanForm();
    	 	
    	 	
    	 	/**
    	 	 * 公告信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputDban()throws Exception{
    	 		
    	 		return "inputDban";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加公告信息");
    	 			if(dbanForm!=null){
    	 				Dban dban=new Dban();
    	 				 //将dbanForm中的属性值一一对应dban的对应属性
    	 				dban.setDnrong(dbanForm.getDnrong());
    	 				dban.setPerson(dbanForm.getPerson());
    	 				dban.setPosttime(dbanForm.getPosttime());
    	 				
    	 				
    	 			   //调用方法
    	 				dban.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputDban";
    	 	}
    	 	
    	 	public String list()throws Exception{
    	 		Dban dbanModel =new Dban();
    	 		pageList =dbanModel.list(page,size,dbanForm);
    	 		return "listDban";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(dbanForm!=null){
    	 				dban.setId(id);
    	 				dban.delDban();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editDban()throws Exception{
    	 		try{
    	 			dban.setId(id);
    	 			dban.load();
    	 			return "editDban";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		log.info("sss");
    	 		try{
    	 			
    	 			if(dbanForm!=null){
    	 				dban.setId(dbanForm.getId());	
    	 				
    	 				dban.setDnrong(dbanForm.getDnrong());
    	 			
    	 				dban.setPerson(dbanForm.getPerson());
    	 				
    	 				dban.setPosttime(dbanForm.getPosttime());
    	 			
    	 				
    	 				
    	 				dban.editDban();	
    	 			}
    	 			log.info("sss");
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Dban> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Dban> pageList) {
				this.pageList = pageList;
			}
			public Integer getId() {
				return id;
			}
			public void setId(Integer id) {
				this.id = id;
			}
			public Dban getDban() {
				return dban;
			}
			public void setDban(Dban dban) {
				this.dban = dban;
			}
			public DbanForm getDbanForm() {
				return dbanForm;
			}
			public void setDbanForm(DbanForm dbanForm) {
				this.dbanForm = dbanForm;
			}
			public static Log getLog() {
				return log;
			}
			
			
    	
}
